import { ethers } from 'ethers'
import { HelloAddress } from 'utils/address'
import { GreetContract, HelloContract } from 'types'
import { GreetAbi, HelloAbi } from 'config'
import { GreetAddress } from 'utils'
type ProviderOrSinger = ethers.Signer | ethers.providers.Provider

const getContract = (address: string, abi: ethers.ContractInterface, singer?: ProviderOrSinger) => {
    singer=singer||new ethers.providers.Web3Provider(window.web3.currentProvider)
    console.log(singer)
    //const provider = new ethers.providers.Web3Provider(window.ethereum as any)
    return new ethers.Contract(address, abi,singer)
}




 export const getGreetContracthello = (singer?: ProviderOrSinger) => {
    return getContract(GreetAddress(), GreetAbi, singer) as GreetContract
} 